package org.wishwork.api.order.action;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.ExtendBase;

/**
 * @description: 订单操作日志查询
 * @author: WangYX
 * @create: 2022-04-13 15:28
 * @Version: 1.0.0
 **/
@EqualsAndHashCode
@Getter
@ToString
public class OrderActionQueryRequest extends ExtendBase {

    /**
     * 内部订单号
     */
    private Integer oId;

    protected OrderActionQueryRequest(Integer pageIndex, Integer pageSize, String modifiedBegin, String modifiedEnd,
                                      Integer oId) {
        super(pageIndex, pageSize, modifiedBegin, modifiedEnd);
        this.oId = oId;
    }

    @Override
    public Builder toBuilder() {
        return new Builder().pageIndex(this.pageIndex).pageSize(this.pageSize).modifiedBegin(this.modifiedBegin)
                .modifiedEnd(this.modifiedEnd).oId(this.oId);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder extends ExtendBase.Builder<Builder, OrderActionQueryRequest> {

        private Integer oId;

        @Override
        public Builder modifiedBegin(String modifiedBegin) {
            this.modifiedBegin = modifiedBegin;
            return this;
        }

        @Override
        public Builder modifiedEnd(String modifiedEnd) {
            this.modifiedEnd = modifiedEnd;
            return this;
        }

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder oId(Integer oId) {
            this.oId = oId;
            return this;
        }

        @Override
        public OrderActionQueryRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageIndex < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 50 : this.pageSize < 0 ? 50 : this.pageSize;
            modifiedTimeHandle(1);
            return new OrderActionQueryRequest(this.pageIndex, this.pageSize, this.modifiedBegin, this.modifiedEnd, this.oId);
        }
    }

}
